package com.zhongfl.crm.lixiao.mapper;

import com.zhongfl.crm.enums.boss.OrderMemorandumAtNoticeSendStatusEnum;
import com.zhongfl.crm.enums.boss.OrderMemorandumSyncStatusEnum;
import com.zhongfl.crm.model.boss.OrderMemorandum;
import com.zhongfl.crm.model.boss.OrderMemorandumQuery;
import com.zhongfl.crm.model.boss.RpOrderMemorandum;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 备忘录 mapper
 *
 * @author tiantian
 * @date 2018/6/13 19:20
 */
public interface OrderMemorandumMapper {

    /**
     * 新增
     */
    Long insert(OrderMemorandum record);

    /**
     * 更新
     */
    void updateById(OrderMemorandum record);

    void updateCustomerOrderNoByOrderNo(@Param("orderNo") String orderNo,@Param("customerOrderNo") String customerOrderNo);

    /**
     * 删除
     */
    void deleteById(@Param("id") Integer id, @Param("staffName") String staffName);

    /**
     * 条件查询
     */
    List<OrderMemorandum> selectByPrarm(OrderMemorandumQuery query);

    List<OrderMemorandum> selectCustomerOrderRevisitLogByParam(OrderMemorandumQuery query);

    /**
     * 根据ID查询评论记录
     */
    List<OrderMemorandum> selectCommentByParentId(Long id);


    /**
     * 根据ID查询评论记录
     */
    List<OrderMemorandum> selectByParentId(Long id);

    /**
     * 更新同步状态
     */
    void updateSyncStatus(@Param("id") Long id, @Param("key") OrderMemorandumSyncStatusEnum key);

    /**
     * 更新消息发送状态
     */
    void updateAtNoticeSendStatus(@Param("id") Long id, @Param("status") OrderMemorandumAtNoticeSendStatusEnum status);

    /**
     * 根据订单号按天分组查询
     * @param orderNo 订单号
     * @return 分组统计信息
     */
    List<RpOrderMemorandum> selectByOrderNoGroupByDay(String orderNo);

    /**
     * 通过订单号和日期查询
     * @param orderNo 订单号
     * @param date 日期
     * @return list
     */
    List<OrderMemorandum> selectByOrderNoAndDay(@Param("orderNo") String orderNo, @Param("date") String date);

    /**
     * 根据父id删除
     * @param parentId 父id
     * @param staffName 当前登录人姓名
     */
    void deleteByParentId(@Param("parentId") Integer parentId, @Param("staffName") String staffName);

    /**
     * 根据主键id查询
     * @param id 主键id
     * @return 跟进记录
     */
    OrderMemorandum selectById(Integer id);

    /**
     * 查询跟进记录
     * @param orderMemorandumQuery
     * @return
     */
    List<OrderMemorandum> selectByQuery(OrderMemorandumQuery orderMemorandumQuery);
}